var connect = require('connect');
var app = connect();
const fs = require('fs');

var WebSocket = require('ws');
var ws = new WebSocket.Server({ port: 8080 });

ws.on('connection', function(ws){
    console.log('server: receive connection');
    ws.on('message', function(msg){
        console.log(`server: received: %s`,msg);
    })

    ws.send('world');
});


app.use('/', function(req, res, next){
    // res.sendFile(__dirname+'/index.html');
    let indexStream = fs.readFileSync(__dirname+'/index.html');
    res.end(indexStream);
})

app.listen(3000);